﻿using Client.Control;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace Client.Windows {
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();

            //ChildWindow page = new ChildWindow();
            ////SystemPage page = new SystemPage(this);  
            //MainPage.Content = page;
        }

        private void RowDefinition_MouseDown(object sender, MouseButtonEventArgs e) {
            if (e.LeftButton == MouseButtonState.Pressed) {
                this.DragMove();
            }
        }

        private void Btn_min_Click(object sender, RoutedEventArgs e) {
            WindowState = WindowState.Minimized;
        }

        private void Btn_max_Click(object sender, RoutedEventArgs e) {
            if (WindowState == WindowState.Normal) {
                WindowState = WindowState.Maximized;
            } else if (WindowState == WindowState.Maximized) {
                WindowState = WindowState.Normal;
            }
        }

        private void Btn_close_Click(object sender, RoutedEventArgs e) {
            Close();
        }

        private void FnButton_Click(object sender, RoutedEventArgs e) {
            FnButton fnButton = (FnButton)sender;
            int childrenCount = VisualTreeHelper.GetChildrenCount(fnButton.Parent);
            for (int i = 0; i < childrenCount; i++) {
                DependencyObject child = VisualTreeHelper.GetChild(fnButton.Parent, i);
                if ("Client.Control.FnButton".Equals(child.GetType().ToString())) {
                    FnButton c = (FnButton)child;
                    c.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00000000"));
                }
            }
            fnButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4C000000"));
        }
    }
}
